package com.lanyam.travel.base.service.impl;


import com.lanyam.travel.base.entity.OrderRefundDetails;
import com.lanyam.travel.base.entity.vo.OrderRefundDetailsVo;
import com.lanyam.travel.base.dao.OrderRefundDetailsMapper;
import com.lanyam.travel.base.service.IOrderRefundDetailsService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;


@Service
@Transactional
@Slf4j
public class OrderRefundDetailsServiceImpl implements IOrderRefundDetailsService {

    @Resource
    private OrderRefundDetailsMapper orderRefundDetailsMapper;

    @Override
    public IPage<OrderRefundDetailsVo> getPageOrderRefundDetails (Map<String, Object> queryMap, Integer page, Integer rows) {
        Page<OrderRefundDetailsVo> pageSize = new Page<OrderRefundDetailsVo>(page, rows);
        Page<OrderRefundDetailsVo> pageInfo = orderRefundDetailsMapper.getPage(pageSize, queryMap);
        return pageInfo;
    }

    @Override
    public void addOrderRefundDetails(OrderRefundDetails orderRefundDetails) {
        orderRefundDetailsMapper.insert(orderRefundDetails);
    }

    @Override
    public void updateOrderRefundDetails(OrderRefundDetails orderRefundDetails) {
        orderRefundDetailsMapper.updateById(orderRefundDetails);
    }

    @Override
    public void delById(String id) {
        orderRefundDetailsMapper.delById(id);
    }

	@Override
	public List<OrderRefundDetails> getVerifyRecords(String refundId) {
		// TODO Auto-generated method stub
		QueryWrapper<OrderRefundDetails> wrapper = new QueryWrapper<OrderRefundDetails>();
		wrapper.eq("refund_id", refundId);
		List<OrderRefundDetails> detailsList = orderRefundDetailsMapper.selectList(wrapper);
		return detailsList;
	}

	@Override
	public OrderRefundDetails getLatestRefundDeatail(String refundId) {
		// TODO Auto-generated method stub
		List<OrderRefundDetails> details = orderRefundDetailsMapper.getLatestRefundDeatail(refundId);
		if(null != details && details.size() > 0)
		{
			return details.get(0);
		}
		return null;
	}
}